package com.twilight.h264.decoder;

public class CAVLCTables {
	
	public static short[][] expandTable(short[][] input) {
		int tableSize = 0;
		// Calculate Table Size.
		for(int i=0;i<input.length;i++)
			tableSize += input[i][2];
		short[][] output = new short[tableSize][2];
		int j = 0;
		for(int i=0;i<input.length;i++) {
			for(int k=0;k<input[i][2];k++) {
				output[j+k][0] = input[i][0];
				output[j+k][1] = input[i][1];
			} // for k
			j += input[i][2];
		} // for i
		return output;
	}
	
	public static final short[][] chroma_dc_coeff_token_vlc_table = {
		   {19, 7, 2}, 
		   {18, 8, 1}, 
		   {17, 8, 1}, 
		   {14, 7, 2}, 
		   {13, 7, 2}, 
		   {16, 6, 4}, 
		   {12, 6, 4}, 
		   {8, 6, 4}, 
		   {15, 6, 4}, 
		   {9, 6, 4}, 
		   {4, 6, 4}, 
		   {10, 3, 32}, 
		   {0, 2, 64}, 
		   {5, 1, 128}, 
		};
		   
		public static final short[][][] coeff_token_vlc_table = {
		    {
		   {256, -8, 1}, 
		   {512, -2, 1}, 
		   {516, -1, 1}, 
		   {518, -1, 1}, 
		   {27, 8, 1}, 
		   {18, 8, 1}, 
		   {13, 8, 1}, 
		   {8, 8, 1}, 
		   {23, 7, 2}, 
		   {14, 7, 2}, 
		   {19, 6, 4}, 
		   {9, 6, 4}, 
		   {4, 6, 4}, 
		   {15, 5, 8}, 
		   {10, 3, 32}, 
		   {5, 2, 64}, 
		   {0, 1, 128}, 
		   {-1, 0, 2}, 
		   {53, 7, 2}, 
		   {64, 8, 1}, 
		   {66, 8, 1}, 
		   {65, 8, 1}, 
		   {60, 8, 1}, 
		   {67, 8, 1}, 
		   {62, 8, 1}, 
		   {61, 8, 1}, 
		   {56, 8, 1}, 
		   {63, 8, 1}, 
		   {58, 8, 1}, 
		   {57, 8, 1}, 
		   {52, 8, 1}, 
		   {59, 7, 2}, 
		   {54, 7, 2}, 
		   {49, 7, 2}, 
		   {48, 7, 2}, 
		   {55, 7, 2}, 
		   {50, 7, 2}, 
		   {45, 7, 2}, 
		   {44, 7, 2}, 
		   {51, 6, 4}, 
		   {46, 6, 4}, 
		   {41, 6, 4}, 
		   {40, 6, 4}, 
		   {47, 6, 4}, 
		   {42, 6, 4}, 
		   {37, 6, 4}, 
		   {36, 6, 4}, 
		   {32, 5, 8}, 
		   {38, 5, 8}, 
		   {33, 5, 8}, 
		   {28, 5, 8}, 
		   {43, 5, 8}, 
		   {34, 5, 8}, 
		   {29, 5, 8}, 
		   {24, 5, 8}, 
		   {39, 3, 32}, 
		   {30, 3, 32}, 
		   {25, 3, 32}, 
		   {20, 3, 32}, 
		   {35, 2, 1}, 
		   {26, 2, 1}, 
		   {21, 2, 1}, 
		   {16, 2, 1}, 
		   {31, 1, 1}, 
		   {22, 1, 1}, 
		   {17, 1, 1}, 
		   {12, 1, 1}, 
		    }, 
		    {
		   {256, -6, 1}, 
		   {320, -3, 1}, 
		   {328, -1, 1}, 
		   {330, -1, 1}, 
		   {20, 8, 1}, 
		   {26, 8, 1}, 
		   {25, 8, 1}, 
		   {16, 8, 1}, 
		   {35, 7, 2}, 
		   {22, 7, 2}, 
		   {21, 7, 2}, 
		   {12, 7, 2}, 
		   {31, 6, 4}, 
		   {18, 6, 4}, 
		   {17, 6, 4}, 
		   {8, 6, 4}, 
		   {27, 6, 4}, 
		   {14, 6, 4}, 
		   {13, 6, 4}, 
		   {4, 6, 4}, 
		   {23, 5, 8}, 
		   {9, 5, 8}, 
		   {19, 4, 16}, 
		   {15, 4, 16}, 
		   {10, 3, 32}, 
		   {5, 2, 64}, 
		   {0, 2, 64}, 
		   {-1, 0, 2}, 
		   {63, 5, 2}, 
		   {67, 6, 1}, 
		   {66, 6, 1}, 
		   {65, 6, 1}, 
		   {64, 6, 1}, 
		   {61, 6, 1}, 
		   {60, 6, 1}, 
		   {62, 6, 1}, 
		   {57, 6, 1}, 
		   {58, 5, 2}, 
		   {56, 5, 2}, 
		   {59, 5, 2}, 
		   {54, 5, 2}, 
		   {53, 5, 2}, 
		   {52, 5, 2}, 
		   {55, 5, 2}, 
		   {50, 5, 2}, 
		   {49, 5, 2}, 
		   {48, 5, 2}, 
		   {44, 4, 4}, 
		   {46, 4, 4}, 
		   {45, 4, 4}, 
		   {40, 4, 4}, 
		   {51, 4, 4}, 
		   {42, 4, 4}, 
		   {41, 4, 4}, 
		   {36, 4, 4}, 
		   {47, 3, 1}, 
		   {38, 3, 1}, 
		   {37, 3, 1}, 
		   {32, 3, 1}, 
		   {43, 3, 1}, 
		   {34, 3, 1}, 
		   {33, 3, 1}, 
		   {28, 3, 1}, 
		   {39, 1, 1}, 
		   {30, 1, 1}, 
		   {29, 1, 1}, 
		   {24, 1, 1}, 
		    }, 
		    {
		   {256, -2, 1}, 
		   {260, -2, 1}, 
		   {264, -2, 1}, 
		   {268, -2, 1}, 
		   {272, -1, 1}, 
		   {274, -1, 1}, 
		   {276, -1, 1}, 
		   {278, -1, 1}, 
		   {51, 8, 1}, 
		   {46, 8, 1}, 
		   {41, 8, 1}, 
		   {36, 8, 1}, 
		   {47, 8, 1}, 
		   {42, 8, 1}, 
		   {37, 8, 1}, 
		   {32, 8, 1}, 
		   {28, 7, 2}, 
		   {24, 7, 2}, 
		   {38, 7, 2}, 
		   {20, 7, 2}, 
		   {43, 7, 2}, 
		   {34, 7, 2}, 
		   {33, 7, 2}, 
		   {16, 7, 2}, 
		   {12, 6, 4}, 
		   {30, 6, 4}, 
		   {29, 6, 4}, 
		   {8, 6, 4}, 
		   {39, 6, 4}, 
		   {26, 6, 4}, 
		   {25, 6, 4}, 
		   {4, 6, 4}, 
		   {21, 5, 8}, 
		   {22, 5, 8}, 
		   {17, 5, 8}, 
		   {18, 5, 8}, 
		   {13, 5, 8}, 
		   {35, 5, 8}, 
		   {14, 5, 8}, 
		   {9, 5, 8}, 
		   {31, 4, 16}, 
		   {27, 4, 16}, 
		   {23, 4, 16}, 
		   {19, 4, 16}, 
		   {15, 4, 16}, 
		   {10, 4, 16}, 
		   {5, 4, 16}, 
		   {0, 4, 16}, 
		   {-1, 0, 1}, 
		   {64, 2, 1}, 
		   {67, 2, 1}, 
		   {66, 2, 1}, 
		   {65, 2, 1}, 
		   {60, 2, 1}, 
		   {63, 2, 1}, 
		   {62, 2, 1}, 
		   {61, 2, 1}, 
		   {56, 2, 1}, 
		   {59, 2, 1}, 
		   {58, 2, 1}, 
		   {57, 2, 1}, 
		   {52, 2, 1}, 
		   {53, 1, 2}, 
		   {48, 1, 1}, 
		   {54, 1, 1}, 
		   {49, 1, 1}, 
		   {44, 1, 1}, 
		   {55, 1, 1}, 
		   {50, 1, 1}, 
		   {45, 1, 1}, 
		   {40, 1, 1}, 
		    }, 
		    {
		   {4, 6, 4}, 
		   {5, 6, 4}, 
		   {-1, 0, 4}, 
		   {0, 6, 4}, 
		   {8, 6, 4}, 
		   {9, 6, 4}, 
		   {10, 6, 4}, 
		   {-1, 0, 4}, 
		   {12, 6, 4}, 
		   {13, 6, 4}, 
		   {14, 6, 4}, 
		   {15, 6, 4}, 
		   {16, 6, 4}, 
		   {17, 6, 4}, 
		   {18, 6, 4}, 
		   {19, 6, 4}, 
		   {20, 6, 4}, 
		   {21, 6, 4}, 
		   {22, 6, 4}, 
		   {23, 6, 4}, 
		   {24, 6, 4}, 
		   {25, 6, 4}, 
		   {26, 6, 4}, 
		   {27, 6, 4}, 
		   {28, 6, 4}, 
		   {29, 6, 4}, 
		   {30, 6, 4}, 
		   {31, 6, 4}, 
		   {32, 6, 4}, 
		   {33, 6, 4}, 
		   {34, 6, 4}, 
		   {35, 6, 4}, 
		   {36, 6, 4}, 
		   {37, 6, 4}, 
		   {38, 6, 4}, 
		   {39, 6, 4}, 
		   {40, 6, 4}, 
		   {41, 6, 4}, 
		   {42, 6, 4}, 
		   {43, 6, 4}, 
		   {44, 6, 4}, 
		   {45, 6, 4}, 
		   {46, 6, 4}, 
		   {47, 6, 4}, 
		   {48, 6, 4}, 
		   {49, 6, 4}, 
		   {50, 6, 4}, 
		   {51, 6, 4}, 
		   {52, 6, 4}, 
		   {53, 6, 4}, 
		   {54, 6, 4}, 
		   {55, 6, 4}, 
		   {56, 6, 4}, 
		   {57, 6, 4}, 
		   {58, 6, 4}, 
		   {59, 6, 4}, 
		   {60, 6, 4}, 
		   {61, 6, 4}, 
		   {62, 6, 4}, 
		   {63, 6, 4}, 
		   {64, 6, 4}, 
		   {65, 6, 4}, 
		   {66, 6, 4}, 
		   {67, 6, 4}, 
		    }, 
		};
		    
		public static final short[][][] chroma_dc_total_zeros_vlc_table = {
		    {
		   {3, 3, 1}, 
		   {2, 3, 1}, 
		   {1, 2, 2}, 
		   {0, 1, 4}, 
		    }, 
		    {
		   {2, 2, 2}, 
		   {1, 2, 2}, 
		   {0, 1, 4}, 
		    }, 
		    {
		   {1, 1, 4}, 
		   {0, 1, 4}, 
		    }, 
		};
		    
		public static final short[][][] total_zeros_vlc = {
		    {
		   {-1, 0, 1}, 
		   {15, 9, 1}, 
		   {14, 9, 1}, 
		   {13, 9, 1}, 
		   {12, 8, 2}, 
		   {11, 8, 2}, 
		   {10, 7, 4}, 
		   {9, 7, 4}, 
		   {8, 6, 8}, 
		   {7, 6, 8}, 
		   {6, 5, 16}, 
		   {5, 5, 16}, 
		   {4, 4, 32}, 
		   {3, 4, 32}, 
		   {2, 3, 64}, 
		   {1, 3, 64}, 
		   {0, 1, 256}, 
		    }, 
		    {
		   {14, 6, 8}, 
		   {13, 6, 8}, 
		   {12, 6, 8}, 
		   {11, 6, 8}, 
		   {10, 5, 16}, 
		   {9, 5, 16}, 
		   {8, 4, 32}, 
		   {7, 4, 32}, 
		   {6, 4, 32}, 
		   {5, 4, 32}, 
		   {4, 3, 64}, 
		   {3, 3, 64}, 
		   {2, 3, 64}, 
		   {1, 3, 64}, 
		   {0, 3, 64}, 
		    }, 
		    {
		   {13, 6, 8}, 
		   {11, 6, 8}, 
		   {12, 5, 16}, 
		   {10, 5, 16}, 
		   {9, 5, 16}, 
		   {8, 4, 32}, 
		   {5, 4, 32}, 
		   {4, 4, 32}, 
		   {0, 4, 32}, 
		   {7, 3, 64}, 
		   {6, 3, 64}, 
		   {3, 3, 64}, 
		   {2, 3, 64}, 
		   {1, 3, 64}, 
		    }, 
		    {
		   {12, 5, 16}, 
		   {11, 5, 16}, 
		   {10, 5, 16}, 
		   {0, 5, 16}, 
		   {9, 4, 32}, 
		   {7, 4, 32}, 
		   {3, 4, 32}, 
		   {2, 4, 32}, 
		   {8, 3, 64}, 
		   {6, 3, 64}, 
		   {5, 3, 64}, 
		   {4, 3, 64}, 
		   {1, 3, 64}, 
		    }, 
		    {
		   {11, 5, 16}, 
		   {9, 5, 16}, 
		   {10, 4, 32}, 
		   {8, 4, 32}, 
		   {2, 4, 32}, 
		   {1, 4, 32}, 
		   {0, 4, 32}, 
		   {7, 3, 64}, 
		   {6, 3, 64}, 
		   {5, 3, 64}, 
		   {4, 3, 64}, 
		   {3, 3, 64}, 
		    }, 
		    {
		   {10, 6, 8}, 
		   {0, 6, 8}, 
		   {1, 5, 16}, 
		   {8, 4, 32}, 
		   {9, 3, 64}, 
		   {7, 3, 64}, 
		   {6, 3, 64}, 
		   {5, 3, 64}, 
		   {4, 3, 64}, 
		   {3, 3, 64}, 
		   {2, 3, 64}, 
		    }, 
		    {
		   {9, 6, 8}, 
		   {0, 6, 8}, 
		   {1, 5, 16}, 
		   {7, 4, 32}, 
		   {8, 3, 64}, 
		   {6, 3, 64}, 
		   {4, 3, 64}, 
		   {3, 3, 64}, 
		   {2, 3, 64}, 
		   {5, 2, 128}, 
		    }, 
		    {
		   {8, 6, 8}, 
		   {0, 6, 8}, 
		   {2, 5, 16}, 
		   {1, 4, 32}, 
		   {7, 3, 64}, 
		   {6, 3, 64}, 
		   {3, 3, 64}, 
		   {5, 2, 128}, 
		   {4, 2, 128}, 
		    }, 
		    {
		   {1, 6, 8}, 
		   {0, 6, 8}, 
		   {7, 5, 16}, 
		   {2, 4, 32}, 
		   {5, 3, 64}, 
		   {6, 2, 128}, 
		   {4, 2, 128}, 
		   {3, 2, 128}, 
		    }, 
		    {
		   {1, 5, 16}, 
		   {0, 5, 16}, 
		   {6, 4, 32}, 
		   {2, 3, 64}, 
		   {5, 2, 128}, 
		   {4, 2, 128}, 
		   {3, 2, 128}, 
		    }, 
		    {
		   {0, 4, 32}, 
		   {1, 4, 32}, 
		   {2, 3, 64}, 
		   {3, 3, 64}, 
		   {5, 3, 64}, 
		   {4, 1, 256}, 
		    }, 
		    {
		   {0, 4, 32}, 
		   {1, 4, 32}, 
		   {4, 3, 64}, 
		   {2, 2, 128}, 
		   {3, 1, 256}, 
		    }, 
		    {
		   {0, 3, 64}, 
		   {1, 3, 64}, 
		   {3, 2, 128}, 
		   {2, 1, 256}, 
		    }, 
		    {
		   {0, 2, 128}, 
		   {1, 2, 128}, 
		   {2, 1, 256}, 
		    }, 
		    {
		   {0, 1, 256}, 
		   {1, 1, 256}, 
		    },
		};
		     
		public static final short[][][] run_vlc_table = {
		    {
		   {1, 1, 4}, 
		   {0, 1, 4}, 
		    }, 
		    {
		   {2, 2, 2}, 
		   {1, 2, 2}, 
		   {0, 1, 4}, 
		    }, 
		    {
		   {3, 2, 2}, 
		   {2, 2, 2}, 
		   {1, 2, 2}, 
		   {0, 2, 2}, 
		    }, 
		    {
		   {4, 3, 1}, 
		   {3, 3, 1}, 
		   {2, 2, 2}, 
		   {1, 2, 2}, 
		   {0, 2, 2}, 
		    }, 
		    {
		   {5, 3, 1}, 
		   {4, 3, 1}, 
		   {3, 3, 1}, 
		   {2, 3, 1}, 
		   {1, 2, 2}, 
		   {0, 2, 2}, 
		    }, 
		    {
		   {1, 3, 1}, 
		   {2, 3, 1}, 
		   {4, 3, 1}, 
		   {3, 3, 1}, 
		   {6, 3, 1}, 
		   {5, 3, 1}, 
		   {0, 2, 2}, 
		    }, 
		};

		public static final short[][] run7_vlc_table = {
		   {64, -5, 1}, 
		   {9, 6, 1}, 
		   {8, 5, 2}, 
		   {7, 4, 4}, 
		   {6, 3, 8}, 
		   {5, 3, 8}, 
		   {4, 3, 8}, 
		   {3, 3, 8}, 
		   {2, 3, 8}, 
		   {1, 3, 8}, 
		   {0, 3, 8}, 
		   {-1, 0, 1}, 
		   {14, 5, 1}, 
		   {13, 4, 2}, 
		   {12, 3, 4}, 
		   {11, 2, 8}, 
		   {10, 1, 16}, 
		};	
		
}